package inicio;

import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

import telas.TelaInicial;
/**
 * 
 * @author Douglas Borges
 * 
 */
public class Inicio extends JFrame {
 
  private static final long serialVersionUID = 1L;
  private Painel painel;


  public Inicio(int tipo) {

    super.setTitle("..::: GPUHelp - Aplicação para Execução Remota de Códigos nas Arquiteturas CUDA e OpenCL :::..");

    Dimension screenSize = this.getToolkit().getScreenSize();
    double largura = screenSize.getWidth();
    double altura = screenSize.getHeight();

    super.setLayout(null);
    Image i = Toolkit.getDefaultToolkit().createImage(this.getClass().getResource("/imagens/back.png"));
    ImageIcon ii = new ImageIcon(i);
    JButton btVoltar = new JButton(ii);
    btVoltar.setBounds((int) largura - 470, 2, 32, 32);
    btVoltar.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        new TelaInicial();
        dispose();
      }
    });
    super.add(btVoltar);
    painel = new Painel(tipo);
    painel.setBounds(0, 0, (int) (largura * 0.99), (int) (altura * 0.90));
    super.add(painel);
    super.setLocation(0, 0);
    super.setExtendedState(JFrame.MAXIMIZED_BOTH);
    super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.setSize(screenSize);

    super.setVisible(true);
  }

}
